<%--
  Created by IntelliJ IDEA.
  User: 于永祥
  Date: 2022/9/29
  Time: 20:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<!doctype html>
<html lang="en" class="pxp-root">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="shortcut icon" href="/static/web/images/favicon.png" type="image/x-icon">
    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600;700&display=swap" rel="stylesheet">
    <link href="/static/web/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/web/css/owl.carousel.min.css">
    <link rel="stylesheet" href="/static/web/css/owl.theme.default.min.css">
    <link rel="stylesheet" href="/static/web/css/animate.css">
    <link rel="stylesheet" href="/static/web/css/style.css">
    <script type="text/javascript" src="/static/web/js/jquery-3.3.1.min.js"></script>

    <title>企业-职位管理</title>
</head>

<script type="text/javascript">
    $(function (){
        searchPosition(1);
        $(".table-responsive").on("click",".checked",enableBatchDele);
        $(".table-responsive").on("click",".selectAll",selectAll);
        $(".batchDele").click(batchDele);
        $(".table-responsive").on("click",".delete",deleOne);

        $(".search").click(function (){
            searchPosition(1);
        });
        $(".table-responsive").on("click",".lastPage",function (){
           let pageNum = parseInt($(".nowPage").html());
           pageNum--;
           searchPosition(pageNum);
           return false;
        });
        $(".table-responsive").on("click",".nextPage",function (){
            let pageNum = parseInt($(".nowPage").html());
            pageNum++;
            searchPosition(pageNum);
            return false;
        });
        $(".table-responsive").on("click",".changePage",function (){
            let pageNum = $(this).html();
            searchPosition(pageNum);
            return false;
        });

    });

    function enableBatchDele(){
        if($(this).prop("checked")==true){
            $(".batchDele").prop("disabled",false);
        }
        else {
            $(".batchDele").prop("disabled",true);
        }
    }

    function searchPosition(pageNum){
        let data = {
            pageNum:pageNum,positionName:null
        }
        let positionName = $(".positionName").val();
        if(positionName!=""){
            data.positionName = positionName;
        }
        $.ajax({
            url:"/web/companies/companyPositionData",
            type:"post",
            data:data,
            success:function (mes){
                $(".table-responsive").html(mes);
                let num = $("#num").val();
                $("#positionNum").html(num);
            }
        });
    }

    function selectAll(){
        $(".radio").prop("checked",$(this).prop("checked"));
        if($(this).prop("checked")==true){
            $(".batchDele").prop("disabled",false);
        }
        else {
            $(".batchDele").prop("disabled",true);
        }
    }

    function batchDele(){
        if(confirm("确定删除吗?")){
            var array = new Array();
            $(".checked:checked").each(function (){
                $(this).parent().parent().remove();
                var positionId = $(this).data("id");
                array.push(positionId);
            });
            $.ajax({
                url:"/web/companies/batchDele",
                type:"post",
                traditional:true,
                data:{
                    positionIds:array
                }
            });
        }
    }

    function deleOne(){
        let positionId = $(this).attr("id").slice(3);
        if(confirm("确定删除吗?")){
            $(this).parent().parent().parent().parent().parent().remove();
            $.ajax({
                url:"/web/companies/deleteOnePosition",
                type:"post",
                data:{
                    positionId:positionId
                }
            });
        }
    }
</script>

<body style="background-color: var(--pxpMainColorLight);">
<div class="pxp-preloader"><span>Loading...</span></div>

<jsp:include page="/web/companies/inc/companyHead"/>

    <div class="pxp-dashboard-content-details">
        <h1>管理职位</h1>
        <p style="font-weight: bold;" class="pxp-text-light">包含所有工作机会的详细列表</p>

        <div class="mt-4 mt-lg-5">
            <div class="row justify-content-between align-content-center">
                <div class="col-auto order-2 order-sm-1">
                    <div class="pxp-company-dashboard-jobs-bulk-actions mb-3">
                        <button class="btn ms-2 batchDele" style="font-weight: bold;" disabled>批量删除</button>
                    </div>
                </div>
                <div class="col-auto order-1 order-sm-2">
                    <div class="pxp-company-dashboard-jobs-search mb-3">
                        <div class="pxp-company-dashboard-jobs-search-results me-3"><span id="positionNum"></span>个职位</div>
                        <div class="pxp-company-dashboard-jobs-search-search-form">
                            <div class="input-group">
                                <span class="input-group-text"><span class="fa fa-search search"></span></span>
                                <input style="font-weight: bold;" type="text" class="form-control positionName" placeholder="查询职位">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <!--职位管理-->
            </div>
        </div>
    </div>

<jsp:include page="/web/companies/inc/companyFoot"/>

</div>

<script src="/static/web/js/jquery-3.4.1.min.js"></script>
<script src="/static/web/js/bootstrap.bundle.min.js"></script>
<script src="/static/web/js/owl.carousel.min.js"></script>
<script src="/static/web/js/nav.js"></script>
<script src="/static/web/js/Chart.min.js"></script>
<script src="/static/web/js/main.js"></script>
</body>
</html>

